<?php
$this->breadcrumbs=array(
	'Sites'=>array('index'),
);

if ($model->id)
    $this->breadcrumbs = CMap::mergeArray($this->breadcrumbs, array($model->name=>array('update','id'=>$model->id),'Update'));
else
    $this->breadcrumbs[] = 'Create';
?>

<h1><?php echo ($model->id) ? 'Edit' : 'Create';?> Site <?php echo $model->name; ?></h1>

<?php 
$tabs = array('Details'=>$this->renderPartial('_form', array('model'=>$model), true));
if ($model->id)
{
    $tabs['URLs'] = array('ajax'=>$this->createUrl('url', array('site_id'=>$model->id)));
}
$this->widget('zii.widgets.jui.CJuiTabs', array(
    'id'=>'site-tabs',
    'tabs'=>$tabs,
    'options'=>array(
        'cache'=>true,
    )
));
Yii::app()->clientScript->registerScriptFile(Yii::app()->core->AssetUrl.'/scripts/gridview.js', CClientScript::POS_BEGIN);
Yii::app()->clientScript->registerScriptFile(Yii::app()->theme->baseUrl.'/scripts/fancybox/jquery.fancybox-1.3.4.pack.js');
Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl.'/scripts/fancybox/jquery.fancybox-1.3.4.css');

$script = "
$('.add-url, .button-column .update').live('click', function(){
    $.fancybox({
        'titleShow'         : false,
        'height'            : 250,
        'autoScale'         : true,
        'transitionIn'      : 'none',
        'transitionOut'     : 'none',
        'type'              : 'iframe',
        'href'              : $(this).attr('href')
    });
    return false;
});
";
Yii::app()->clientScript->registerScript(__CLASS__.'#AddUrl', $script, CClientScript::POS_READY);
$script = "
\$.reloadSiteUrlTab = function(){
    $('#site-tabs').tabs('load', 1);
}
";
Yii::app()->clientScript->registerScript(__CLASS__.'#ReloadSiteUrl', $script, CClientScript::POS_HEAD);

$script = "
\$('.grid-view .status-column a').live('click', function(){
    if (\$(this).parent().hasClass('default'))
        return false;
    $.get(\$(this).attr('href'), function(){
        $('.grid-view .filters input').trigger('change');
    });
    return false;
});
";
Yii::app()->clientScript->registerScript(__CLASS__.'#ChangeStatus', $script, CClientScript::POS_READY);

$baseScriptUrl=Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('zii.widgets.assets')).'/gridview';
Yii::app()->getClientScript()->registerCssFile($baseScriptUrl.'/styles.css');
$cs=Yii::app()->getClientScript();
$cs->registerCoreScript('jquery');
$cs->registerCoreScript('bbq');
$cs->registerScriptFile($baseScriptUrl.'/jquery.yiigridview.js',CClientScript::POS_END);
?>